package Brute_force_method;

import java.util.ArrayList;
import java.util.List;



import java.math.*;

class point{
	double x;
	double y;
	public point(double x,double y){
		this.x=x;
		this.y=y;
	}
}
public class violence {
	
	
	public static double[] Nearest_point_pair(List<point> in) {
		double[] out=new double[3];//out[0]和out[1]存放最近点对的下标，out[2]存放最近点对的距离
		double S=100000;
		if(in.size()==1||in.size()==0) {
			return out;
		}
//		if(in.size()==2) {
//			S=dist(in.get(0),in.get(1));
//			out[0]=0;
//			out[1]=1;
//			out[2]=S;
//			return out;
//		}
		for(int i=0;i<in.size();i++) {
			for(int j=in.size()-1;j>i;j--) {
				if(S>dist(in.get(i),in.get(j))) {
					S=dist(in.get(i),in.get(j));
					out[0]=i;
					out[1]=j;
					out[2]=S;
					System.out.println(S);
				}
			}
		}
		return out;
	}
	
	public static double dist(point p1,point p2) {
		return Math.sqrt(Math.pow((p2.x-p1.x), 2)+Math.pow((p2.y-p1.y), 2));
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		point a1=new point(569,241);
		point a2=new point(231,433);
		point a3=new point(345,987);
		point a4=new point(564,897);
		point a5=new point(134,897);
		point a6=new point(908,234);
		point a7=new point(687,343);
		point a8=new point(569,246);
		point a9=new point(679,146);
		point a0=new point(681,874);
		List<point> in=new ArrayList<point>();
		in.add(a1);in.add(a0);in.add(a9);in.add(a8);in.add(a7);in.add(a6);in.add(a5);in.add(a4);in.add(a3);in.add(a2);
		double[] out=new double[3];
		out=Nearest_point_pair(in);
		
		System.out.println(out[0]+","+out[1]+","+out[2]);
	}

}
